﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MvcForum.Net.Bussiness
{
    public class UserInfo
    {
        public int UserId { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
        public float TimeZone { get; set; }
        /*public int TotalMessages{get;set;}*/

        public int RoleId { get; set; }

        public int MessagesNoRead { get; set; }

        public bool IsAdmin { get; set; }

        public bool IsActived { get; set; }

        public bool IsSuperModerator { get; set; }

        public bool IsMod
        {
            get
            {
                return IsAdmin || IsSuperModerator || (Moderates != null && Moderates.Count > 0);
            }

        }


        public DateTime LastPosted{get;set;}

        public DateTime? LastSearched{get;set;}

        public DateTime LastNotifyCheck { get; set; }

        public List<Moderator> Moderates{get;set;}

        public AccessMask Permissions{get;set;}

        public string Avatar { get; set; }

        public bool? Sex { get; set; }

        public string AccessMask { get; set; }

        public Moderator Mod(int forumId)
        {
            return Moderates != null ? Moderates.Find(x => x.ForumId == forumId) : null;
        }

        public bool IsModerated(int forumId)
        {
          return IsAdmin || IsSuperModerator || (Moderates!=null && Moderates.Any(x => x.ForumId == forumId));
        }


       

    }
}
